package com.ssh;

import org.junit.Test;

public class CheckPossibility_655 { 
	public boolean checkPossibility(int[] nums) {
		int s = 0;
		boolean t = true;
        for (int i = 0; i < nums.length; i++) {
        	if (nums[i] < nums[i-1 < 0 ? 0 :i-1]) {
        		s++;
        		if (nums[i] < nums[i-2 < 0 ? i : i-2]) {
        			nums[i] = nums[i-1];
        		}else {
        			nums[i-1] = nums[i];
        		}
        		if (s == 2) {
        			t = false;
        			break;
        		}
        	}
        }
        return t;
    }
	@Test
	public void test() {
		int[] a = {4,2,3};
		System.out.println(checkPossibility(a));
	}
	
}
